package com.b511.swpu.cementbackend;

import com.b511.swpu.cementbackend.dto.input.SysCompanyInputDto;
import com.b511.swpu.cementbackend.service.SysCompanyService;
import com.b511.swpu.cementbackend.service.DevService;
import com.b511.swpu.cementbackend.service.MetaDictService;
import com.b511.swpu.cementbackend.dto.input.MetaDictInputDto;
import com.b511.swpu.cementbackend.entity.*;
import com.b511.swpu.cementbackend.repository.*;
import com.b511.swpu.cementbackend.util.Help;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.client.AutoConfigureWebClient;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.domain.PageRequest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional;

import javax.persistence.Table;
import java.math.BigDecimal;
import java.util.*;

@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
public class MockSystemData {

    // 注入 BA_WELL Repository
    @Autowired
    BA_WellRepository wellRepository;

    @Autowired
    MetaSystemUnitRepository metaSystemUnitRepository;

    @Autowired
    MetaFieldRepository metaFieldRepository;

    @Autowired
    MetaDictRepository metaDictRepository;

    @Autowired
    MetaSystemUnitValueRepository metaSystemUnitValueRepository;

    @Autowired
    MetaTableRepository metaTableRepository;

    @Autowired
    SysMenuRepository sysMenuRepository;

    @Autowired
    SysRoleRepository sysRoleRepository;

    @Autowired
    SysUserRepository sysUserRepository;



    @Test
    public void queryMetaSystemUnit(){
        System.out.println(metaSystemUnitRepository.findAll(PageRequest.of(5,10)));
    }

    @Test
    public void queryMetaField(){
        System.out.println(metaFieldRepository.findAll(PageRequest.of(5,10)).getSize());
    }

    @Test
    public void queryMetaDict(){
        System.out.println(metaDictRepository.findAll(PageRequest.of(5,10)).getSize());
    }

    @Test
    public void queryMetaSystemUnitValue(){
        System.out.println(metaSystemUnitValueRepository.findAll(PageRequest.of(5,10)).getSize());
    }

    @Test
    public void queryMetaTable(){
        System.out.println(metaTableRepository.findAll(PageRequest.of(5,10)).getSize());
    }

    @Test
    public void querySysMenu(){
        System.out.println(sysMenuRepository.findAll(PageRequest.of(5,10)).getSize());
    }

    @Test
    public void querySysRole(){
        System.out.println(sysRoleRepository.findAll(PageRequest.of(5,10)).getSize());
    }

    @Test
    public void querySysUser(){
        System.out.println(sysUserRepository.findAll().size());
    }


    // BA_SPECIALSTRATUM 插入测试数据
    @Autowired
    BA_SpecialStratumRepository specialStratumRepository;
    @Test
    public void initSpecialStratumData(){
        List<BA_Well> wellList = wellRepository.findAll();
        List<BA_SpecialStratum> specialStratumList = new ArrayList<>();
        for(int i=0; i<100; i++){
            BA_SpecialStratum specialStratum = new BA_SpecialStratum();
            BA_Well tmp_well = wellList.get(U.i(wellList.size()));

            specialStratum.setWell(tmp_well)
                    .setBottomDepth(U.f(5000))
                    .setBottomVerticalDepth(U.f(3000))
                    .setWellName(tmp_well.getWellName());
            specialStratumList.add(specialStratum);
        }
        specialStratumRepository.saveAll(specialStratumList);
    }

    // BA_STRATUM 插入测试数据
    @Autowired
    BA_StratumRepository stratumRepository;
    @Test
    public void initStratumData(){
        List<BA_Well> wellList = wellRepository.findAll();
        List<BA_Stratum> stratumList = new ArrayList<>();
        for(int i=0; i<100; i++){
            BA_Stratum stratum = new BA_Stratum();
            BA_Well tmp_well = wellList.get(U.i(wellList.size()));
            stratum.setWell(tmp_well)
                    .setBottomDepth(U.f(2000))
                    .setBottomVertical(U.f(2000))
                    .setThickness(U.f(200))
                    .setWellName(tmp_well.getWellName());

            stratumList.add(stratum);
        }
        stratumRepository.saveAll(stratumList);
    }

    // BA_SEA_AREA 插入测试数据
    @Autowired
    BA_SeaAreaRepository seaAreaRepository;
    @Test
    public void initSeaAreaData(){
        List<BA_Well> wellList = wellRepository.findAll();
        List<BA_SeaArea> seaAreaList = new ArrayList<>();
        for(int i=0; i<100; i++){
            BA_SeaArea seaArea = new BA_SeaArea();
            BA_Well tmp_well = wellList.get(U.i(wellList.size()));

            seaArea.setWell(tmp_well)
                    .setDensity(U.f(20))
                    .setWaterTemperature(U.f(200))
                    .setWellName(tmp_well.getWellName());
            seaAreaList.add(seaArea);
        }
        seaAreaRepository.saveAll(seaAreaList);
    }

    // BA_CollapsePressure 插入测试数据
    @Autowired
    BA_CollapsePressureRepository collapsePressureRepository;
    @Test
    public void initCollapseData(){
        List<BA_Well> wellList = wellRepository.findAll();
        List<BA_CollapsePressure> collapsePressureList = new ArrayList<>();
        for(int i=0; i<100; i++){
            BA_CollapsePressure collapsePressure = new BA_CollapsePressure();
            BA_Well tmp_well = wellList.get(U.i(wellList.size()));

            collapsePressure.setWell(tmp_well)
                    .setWellDepth(U.f(5000))
                    .setVerticalDepth(U.f(5000))
                    .setCollapsePressureED(U.f(5))
                    .setWellName(tmp_well.getWellName());
            collapsePressureList.add(collapsePressure);
        }
        collapsePressureRepository.saveAll(collapsePressureList);
    }

    // BA_FLOOR_DRAIN 插入测试数据
    @Autowired
    BA_FloorDrainRepository floorDrainRepository;
    @Test
    public void initFloorDrainData(){
        List<BA_Well> wellList = wellRepository.findAll();
        List<BA_FloorDrain> floorDrainList = new ArrayList<>();
        for(int i=0; i<100; i++){
            BA_FloorDrain floorDrain = new BA_FloorDrain();
            BA_Well tmp_well = wellList.get(U.i(wellList.size()));

            floorDrain.setWell(tmp_well)
                    .setWellDepth(U.f(5000))
                    .setVerticalDepth(U.f(5000))
                    .setCasingSize(U.f(300))
                    .setWellName(tmp_well.getWellName());
            floorDrainList.add(floorDrain);
        }
        floorDrainRepository.saveAll(floorDrainList);
    }

    // BA_FRACTURE_PRESSURE 插入测试数据
    @Autowired
    BA_FracturePressureRepository fracturePressureRepository;
    @Test
    public void initFractureData(){
        List<BA_Well> wellList = wellRepository.findAll();
        List<BA_FracturePressure> fracturePressureList = new ArrayList<>();
        for(int i=0; i<100; i++){
            BA_FracturePressure fracturePressure = new BA_FracturePressure();
            BA_Well tmp_well = wellList.get(U.i(wellList.size()));

            fracturePressure.setWell(tmp_well)
                    .setWellDepth(U.f(5000))
                    .setVerticalDepth(U.f(5000))
                    .setPressure(U.f(2300))
                    .setWellName(tmp_well.getWellName());
            fracturePressureList.add(fracturePressure);
        }
        fracturePressureRepository.saveAll(fracturePressureList);
    }

    // BA_GAS_WATER_LAYER 插入测试数据
    @Autowired
    BA_GasWaterLayerRepository gasWaterLayerRepository;
    @Test
    public void initGasWaterData(){
        List<BA_Well> wellList = wellRepository.findAll();
        List<BA_GasWaterLayer> gasWaterLayerList = new ArrayList<>();
        for(int i=0; i<100; i++){
            BA_GasWaterLayer gasWaterLayer = new BA_GasWaterLayer();
            BA_Well tmp_well = wellList.get(U.i(wellList.size()));

            gasWaterLayer.setWell(tmp_well)
                    .setBottomDepth(U.f(5000))
                    .setBottomVerticalDepth(U.f(5000))
                    .setThickness(U.f(2000))
                    .setWellName(tmp_well.getWellName());
            gasWaterLayerList.add(gasWaterLayer);
        }
        gasWaterLayerRepository.saveAll(gasWaterLayerList);
    }

    // BA_LOSSPRESSURE 插入测试数据
    @Autowired
    BA_LossPressureRepository lossPressureRepository;
    @Test
    public void initLossPressureData(){
        List<BA_Well> wellList = wellRepository.findAll();
        List<BA_LossPressure> lossPressureList = new ArrayList<>();
        for(int i=0; i<100; i++){
            BA_LossPressure lossPressure = new BA_LossPressure();
            BA_Well tmp_well = wellList.get(U.i(wellList.size()));

            lossPressure.setWell(tmp_well)
                    .setWellDepth(U.f(5000))
                    .setVerticalDepth(U.f(5000))
                    .setLossPressureECD(U.f(5))
                    .setWellName(tmp_well.getWellName());
            lossPressureList.add(lossPressure);
        }
        lossPressureRepository.saveAll(lossPressureList);
    }

    // BA_PORE_PRESSURE 插入测试数据
    @Autowired
    BA_PorePressureRepository porePressureRepository;
    @Test
    public void initPorePressureData(){
        List<BA_Well> wellList = wellRepository.findAll();
        List<BA_PorePressure> porePressureList = new ArrayList<>();
        for(int i=0; i<100; i++){
            BA_PorePressure porePressure = new BA_PorePressure();
            BA_Well tmp_well = wellList.get(U.i(wellList.size()));

            porePressure.setWell(tmp_well)
                    .setWellDepth(U.f(5000))
                    .setVerticalDepth(U.f(5000))
                    .setPorePressureED(U.f(5))
                    .setWellName(tmp_well.getWellName());
            porePressureList.add(porePressure);
        }
        porePressureRepository.saveAll(porePressureList);
    }

    // BA_STRATUM_LITHOLOGY 插入测试数据
    @Autowired
    BA_StratumLithologyRepository stratumLithologyRepository;
    @Test
    public void initLithologyData(){
        List<BA_Well> wellList = wellRepository.findAll();
        List<BA_StratumLithology> lithologyList = new ArrayList<>();
        for(int i=0; i<100; i++){
            BA_StratumLithology stratumLithology = new BA_StratumLithology();
            BA_Well tmp_well = wellList.get(U.i(wellList.size()));

            stratumLithology.setWell(tmp_well)
                    .setDepth(U.f(5000))
                    .setVertical(U.f(5000))
                    .setRockDensity(U.f(5))
                    .setWellName(tmp_well.getWellName());
            lithologyList.add(stratumLithology);
        }
        stratumLithologyRepository.saveAll(lithologyList);
    }

    // BA_STRATUMTEMPTURE 插入测试数据
    @Autowired
    BA_StratumTemperatureRepository stratumTemperatureRepository;
    @Test
    public void initStratumTemptureData(){
        List<BA_Well> wellList = wellRepository.findAll();
        List<BA_StratumTemperature> stratumTemperatureList = new ArrayList<>();
        for(int i=0; i<100; i++){
            BA_StratumTemperature stratumTemperature = new BA_StratumTemperature();
            BA_Well tmp_well = wellList.get(U.i(wellList.size()));

            stratumTemperature.setWell(tmp_well)
                    .setBeginDepth(U.f(1000))
                    .setEndDepth(U.f(5000))
                    .setTemperature(U.f(300))
                    .setWellName(tmp_well.getWellName());
            stratumTemperatureList.add(stratumTemperature);
        }
        stratumTemperatureRepository.saveAll(stratumTemperatureList);
    }

    // BA_TARGETSTRATUM 插入测试数据
    @Autowired
    BA_TargetStratumRepository targetStratumRepository;
    @Test
    public void initTargetStratumData(){
        List<BA_Well> wellList = wellRepository.findAll();
        List<BA_TargetStratum> targetStratumList = new ArrayList<>();
        for(int i=0; i<100; i++){
            BA_TargetStratum targetStratum = new BA_TargetStratum();
            BA_Well tmp_well = wellList.get(U.i(wellList.size()));

            targetStratum.setWell(tmp_well)
                    .setStratumName("StratumName"+i)
                    .setStratumType("StratumType"+i)
                    .setWellName(tmp_well.getWellName());
            targetStratumList.add(targetStratum);
        }
        targetStratumRepository.saveAll(targetStratumList);
    }

    // BA_WELL_STRUCTURE 插入测试数
    @Autowired
    BA_WellStructureRepository wellStructureRepository;
    @Test
    public void initWellStructureData(){
        List<BA_Well> wellList = wellRepository.findAll();
        List<BA_WellStructure> wellStructureList = new ArrayList<>();
        for(int i=0; i<100; i++){
            BA_WellStructure wellStructure = new BA_WellStructure();
            BA_Well tmp_well = wellList.get(U.i(wellList.size()));

            wellStructure.setWell(tmp_well)
                    .setWellDepth(U.f(5000))
                    .setHoleSize(U.f(5000))
                    .setCasingSize(U.f(300))
                    .setWellName(tmp_well.getWellName());
            wellStructureList.add(wellStructure);
        }
        wellStructureRepository.saveAll(wellStructureList);
    }

    // DR_COMPLEX 插入测试数据
    @Autowired
    DR_ComplexRepository complexRepository;
    @Test
    public void initComplexData(){
        List<BA_Well> wellList = wellRepository.findAll();
        List<DR_Complex> complexList = new ArrayList<>();
        for(int i=0; i<100; i++){
            DR_Complex complex = new DR_Complex();
            BA_Well tmp_well = wellList.get(U.i(wellList.size()));

            complex.setWell(tmp_well)
                    .setHoleSize(U.f(5000))
                    .setComplexType("ComplexType"+i)
                    .setWellName(tmp_well.getWellName());
            complexList.add(complex);
        }
        complexRepository.saveAll(complexList);
    }

    // DR_DRIFITING_SITUATION 插入测试数据
    @Autowired
    DR_DriftingSituationRepository driftingSituationRepository;
    @Test
    public void initDriftingData(){
        List<BA_Well> wellList = wellRepository.findAll();
        List<DR_DriftingSituation> driftingSituationList = new ArrayList<>();
        for(int i=0; i<100; i++){
            DR_DriftingSituation drift = new DR_DriftingSituation();
            BA_Well tmp_well = wellList.get(U.i(wellList.size()));

            drift.setWell(tmp_well)
                    .setGasChannelingVelocity(U.f(50))
                    .setDrillCollarAV(U.f(7))
                    .setMaxTotalGas(U.f(500))
                    .setWellName(tmp_well.getWellName());
            driftingSituationList.add(drift);
        }
        driftingSituationRepository.saveAll(driftingSituationList);
    }

    // DR_DRILL_BIT 插入测试数据
    @Autowired
    DR_DrillBitRepository drillBitRepository;
    @Test
    public void initDrillBitData(){
        List<BA_Well> wellList = wellRepository.findAll();
        List<DR_DrillBit> drillBitList = new ArrayList<>();
        for(int i=0; i<100; i++){
            DR_DrillBit drillBit = new DR_DrillBit();
            BA_Well tmp_well = wellList.get(U.i(wellList.size()));

            drillBit.setWell(tmp_well)
                    .setBitSize(U.f(300))
                    .setWaterHoleSize(U.f(300))
                    .setWellName(tmp_well.getWellName());
            drillBitList.add(drillBit);
        }
        drillBitRepository.saveAll(drillBitList);
    }

    // DR_DRILLING_TOOLS_ASSEMBLY 插入测试数据
    @Autowired
    DR_DrillToolAssemblyRepository drillToolAssemblyRepository;
    @Test
    public void initDrillToolData(){
        List<BA_Well> wellList = wellRepository.findAll();
        List<DR_DrillToolAssembly> toolAssemblyList = new ArrayList<>();
        for(int i=0; i<100; i++){
            DR_DrillToolAssembly toolAssembly = new DR_DrillToolAssembly();
            BA_Well tmp_well = wellList.get(U.i(wellList.size()));

            toolAssembly.setWell(tmp_well)
                    .setAmount(U.i(30))
                    .setDepth(U.f(3000))
                    .setOutDiameter(U.f(300))
                    .setWellName(tmp_well.getWellName());
            toolAssemblyList.add(toolAssembly);
        }
        drillToolAssemblyRepository.saveAll(toolAssemblyList);
    }

    // DR_DRILLING_PUMP 插入测试数据
    @Autowired
    DR_DrillingPumpRepository pumpRepository;
    @Test
    public void initPumpData(){
        List<BA_Well> wellList = wellRepository.findAll();
        List<DR_DrillingPump> pumpList = new ArrayList<>();
        for(int i=0; i<100; i++){
            DR_DrillingPump pump = new DR_DrillingPump();
            BA_Well tmp_well = wellList.get(U.i(wellList.size()));

            pump.setWell(tmp_well)
                    .setDisplacement(U.f(30))
                    .setStoke(U.f(3000))
                    .setDiameter(U.f(300))
                    .setWellName(tmp_well.getWellName());
            pumpList.add(pump);
        }
        pumpRepository.saveAll(pumpList);
    }

    // DR_DRILLING_SITTUATION 插入测试数据
    @Autowired
    DR_DrillingSituationRepository situationRepository;
    @Test
    public void initDrillingSituationData(){
        List<BA_Well> wellList = wellRepository.findAll();
        List<DR_DrillingSituation> situationList = new ArrayList<>();
        for(int i=0; i<100; i++){
            DR_DrillingSituation situation = new DR_DrillingSituation();
            BA_Well tmp_well = wellList.get(U.i(wellList.size()));

            situation.setWell(tmp_well)
                    .setTotalGasDepth(U.f(3000))
                    .setTotalGasMaxValue(U.f(5000))
                    .setFluidDensity(U.f(10))
                    .setWellName(tmp_well.getWellName());
            situationList.add(situation);
        }
        situationRepository.saveAll(situationList);
    }

    // DR_FLUID_DESIGN 插入测试数据
    @Autowired
    DR_FluidDesignRepository fluidDesignRepository;
    @Test
    public void initFluidDesignData(){
        List<BA_Well> wellList = wellRepository.findAll();
        List<DR_FluidDesign> fluidDesignList = new ArrayList<>();
        for(int i=0; i<100; i++){
            DR_FluidDesign fluidDesign = new DR_FluidDesign();
            BA_Well tmp_well = wellList.get(U.i(wellList.size()));

            fluidDesign.setWell(tmp_well)
                    .setBitSize(U.f(300))
                    .setDensity(U.f(10))
                    .setGEL10M(U.f(20))
                    .setWellName(tmp_well.getWellName());
            fluidDesignList.add(fluidDesign);
        }
        fluidDesignRepository.saveAll(fluidDesignList);
    }

    // DR_FLUID_PERFORMANCE 插入测试数据
    @Autowired
    DR_FluidPerformanceRepository fluidPerformanceRepository;
    @Test
    public void initFluidPerformanceData(){
        List<BA_Well> wellList = wellRepository.findAll();
        List<DR_FluidPerformance> fluidPerformanceList = new ArrayList<>();
        for(int i=0; i<100; i++){
            DR_FluidPerformance fluidPerformance = new DR_FluidPerformance();
            BA_Well tmp_well = wellList.get(U.i(wellList.size()));

            fluidPerformance.setWell(tmp_well)
                    .setBitSize(U.f(300))
                    .setDensity(U.f(10))
                    .setGEL10M(U.f(20))
                    .setRPM600(U.f(600))
                    .setRPM300(U.f(300))
                    .setWellName(tmp_well.getWellName());
            fluidPerformanceList.add(fluidPerformance);
        }
        fluidPerformanceRepository.saveAll(fluidPerformanceList);
    }

    // DR_LOG_DATA 插入测试数据
    @Autowired
    DR_LogDataRepository logDataRepository;
    @Test
    public void initDrLogData(){
        List<BA_Well> wellList = wellRepository.findAll();
        List<DR_LogData> drLogDataList = new ArrayList<>();
        for(int i=0; i<100; i++){
            DR_LogData drLogData = new DR_LogData();
            BA_Well tmp_well = wellList.get(U.i(wellList.size()));

            drLogData.setWell(tmp_well)
                    .setInTemperature(U.f(300))
                    .setOutTemperature(U.f(30))
                    .setPumpPressure(U.f(20))
                    .setWellName(tmp_well.getWellName());
            drLogDataList.add(drLogData);
        }
        logDataRepository.saveAll(drLogDataList);
    }

    // DR_LOGGING_DIAMETER 插入测试数据
    @Autowired
    DR_LoggingDiameterRepository loggingDiameterRepository;
    @Test
    public void initLoggingDiameterData(){
        List<BA_Well> wellList = wellRepository.findAll();
        List<DR_LoggingDiameter> dr_loggingDiameterList = new ArrayList<>();
        for(int i=0; i<100; i++){
            DR_LoggingDiameter drLoggingDiameter = new DR_LoggingDiameter();
            BA_Well tmp_well = wellList.get(U.i(wellList.size()));

            drLoggingDiameter.setWell(tmp_well)
                    .setDepth(U.f(3000))
                    .setLogAvgDiameter(U.f(300))
                    .setAvgDiameter(U.f(200))
                    .setWellName(tmp_well.getWellName());
            dr_loggingDiameterList.add(drLoggingDiameter);
        }
        loggingDiameterRepository.saveAll(dr_loggingDiameterList);
    }

    // DR_LOGGING_TEMPRATURE 插入测试数据
    @Autowired
    DR_LoggingTemperatureRepository loggingTemperatureRepository;
    @Test
    public void initLoggingTempData(){
        List<BA_Well> wellList = wellRepository.findAll();
        List<DR_LoggingTemperature> dr_loggingDiameterList = new ArrayList<>();
        for(int i=0; i<100; i++){
            DR_LoggingTemperature drLoggingDiameter = new DR_LoggingTemperature();
            BA_Well tmp_well = wellList.get(U.i(wellList.size()));

            drLoggingDiameter.setWell(tmp_well)
                    .setDepth1(U.f(3000))
                    .setDepth2(U.f(3000))
                    .setDepth3(U.f(3000))
                    .setWellName(tmp_well.getWellName());
            dr_loggingDiameterList.add(drLoggingDiameter);
        }
        loggingTemperatureRepository.saveAll(dr_loggingDiameterList);
    }

    // DR_MEASURED_DATA 插入测试数据
    @Autowired
    DR_MeasuredDataRepository measuredDataRepository;
    @Test
    public void initMeasuredData(){
        List<BA_Well> wellList = wellRepository.findAll();
        List<DR_MeasuredData> dr_measuredDataList = new ArrayList<>();
        for(int i=0; i<100; i++){
            DR_MeasuredData dr_measuredData = new DR_MeasuredData();
            BA_Well tmp_well = wellList.get(U.i(wellList.size()));

            dr_measuredData.setWell(tmp_well)
                    .setWellDepth(U.f(3000))
                    .setCyclicTemperature(U.f(300))
                    .setVerticalDepth(U.f(3000))
                    .setWellName(tmp_well.getWellName());
            dr_measuredDataList.add(dr_measuredData);
        }
        measuredDataRepository.saveAll(dr_measuredDataList);
    }

    // DR_WELL_TRAJECTORY 插入测试数据
    @Autowired
    DR_WellTrajectoryRepository wellTrajectoryRepository;
    @Test
    public void initWellTrajectoryData(){
        List<BA_Well> wellList = wellRepository.findAll();
        List<DR_WellTrajectory> wellTrajectoryList = new ArrayList<>();
        for(int i=0; i<100; i++){
            DR_WellTrajectory wellTrajectory = new DR_WellTrajectory();
            BA_Well tmp_well = wellList.get(U.i(wellList.size()));

            wellTrajectory.setWell(tmp_well)
                    .setWellDepth(U.f(3000))
                    .setAngular(U.f(10))
                    .setVerticalDepth(U.f(3000))
                    .setWellName(tmp_well.getWellName());
            wellTrajectoryList.add(wellTrajectory);
        }
        wellTrajectoryRepository.saveAll(wellTrajectoryList);
    }

    // CM_BASIC 插入测试数据
    @Autowired
    CM_BasicRepository basicRepository;
    @Test
    public void initCmBasicData(){
        List<BA_Well> wellList = wellRepository.findAll();
        List<CM_Basic> basicList = new ArrayList<>();
        for(int i=0; i<100; i++){
            CM_Basic cm_basic = new CM_Basic();
            BA_Well tmp_well = wellList.get(U.i(wellList.size()));

            cm_basic.setWell(tmp_well)
                    .setWellDepth(U.f(3000))
                    .setFangYu(U.f(10))
                    .setCasingShoe(U.f(30))
                    .setFloatCollar(U.f(3000))
                    .setWellName(tmp_well.getWellName());
            basicList.add(cm_basic);
        }
        basicRepository.saveAll(basicList);
    }

    // CM_CASING_TABLE 插入测试数据
    @Autowired
    CM_CasingTableRepository casingTableRepository;
    @Test
    public void initCasingTableData(){
        List<CM_Basic> basicList = basicRepository.findAll();
        List<CM_CasingTable> casingTableList = new ArrayList<>();
        for(int i=0; i<100; i++){
            CM_CasingTable cm_casingTable = new CM_CasingTable();
            CM_Basic tmp_Basic = basicList.get(U.i(basicList.size()));

            cm_casingTable.setBasic(tmp_Basic)
                    .setBa_well_id(tmp_Basic.getWell().getBA_WELL_ID())
                    .setCasingSize(U.f(300))
                    .setNO(U.i(100))
                    .setTopDepth(U.f(3000))
                    .setWellName(tmp_Basic.getWellName());
            casingTableList.add(cm_casingTable);
        }
        casingTableRepository.saveAll(casingTableList);
    }

    // CM_WK_CEMENT_EVALUATION 插入测试数据
    @Autowired
    CM_CementEvaluationRepository cementEvaluationRepository;
    @Test
    public void initCementEvaluationData(){
        List<CM_Basic> basicList = basicRepository.findAll();
        List<CM_WK_CementEvaluation> cementEvaluationList = new ArrayList<>();
        for(int i=0; i<100; i++){
            CM_WK_CementEvaluation cm_wk_cementEvaluation = new CM_WK_CementEvaluation();
            CM_Basic tmp_Basic = basicList.get(U.i(basicList.size()));

            cm_wk_cementEvaluation.setBasic(tmp_Basic)
                    .setBa_well_id(tmp_Basic.getWell().getBA_WELL_ID())
                    .setCasingSize(U.f(300))
                    .setBOC1(U.f(100))
                    .setBOC2(U.f(300))
                    .setWellName(tmp_Basic.getWellName());
            cementEvaluationList.add(cm_wk_cementEvaluation);
        }
        cementEvaluationRepository.saveAll(cementEvaluationList);
    }

    // CM_CENTRALIZER_DESIGN 插入测试数据
    @Autowired
    CM_CentralizerDesignRepository centralizerDesignRepository;
    @Test
    public void initCentralizerDesignData(){
        List<CM_Basic> basicList = basicRepository.findAll();
        List<CM_CentralizerDesign> centralizerDesignList = new ArrayList<>();
        for(int i=0; i<100; i++){
            CM_CentralizerDesign tempData = new CM_CentralizerDesign();
            CM_Basic tmp_Basic = basicList.get(U.i(basicList.size()));

            tempData.setBasic(tmp_Basic)
                    .setBa_well_id(tmp_Basic.getWell().getBA_WELL_ID())
                    .setCasingSize(U.f(300))
                    .setTopDepth(U.f(4000))
                    .setAmount(U.f(30))
                    .setWellName(tmp_Basic.getWellName());
            centralizerDesignList.add(tempData);
        }
        centralizerDesignRepository.saveAll(centralizerDesignList);
    }

    // CM_CENTRICITY_FRICTION 插入测试数据
    @Autowired
    CM_CentricityFrictionRepository centricityFrictionRepository;
    @Test
    public void initCentricityCFricationData(){
        List<CM_Basic> basicList = basicRepository.findAll();
        List<CM_CentricityFriction> centralizerDesignList = new ArrayList<>();
        for(int i=0; i<100; i++){
            CM_CentricityFriction tempData = new CM_CentricityFriction();
            CM_Basic tmp_Basic = basicList.get(U.i(basicList.size()));

            tempData.setBasic(tmp_Basic)
                    .setBa_well_id(tmp_Basic.getWell().getBA_WELL_ID())
                    .setCasingSize(U.f(300))
                    .setMudDensity(U.f(10))
                    .setDepth(U.f(5000))
                    .setWellName(tmp_Basic.getWellName());
            centralizerDesignList.add(tempData);
        }
        centricityFrictionRepository.saveAll(centralizerDesignList);
    }

    // CM_CENTRICITY_RESULT 插入测试数据
    @Autowired
    CM_CentricityResultRepository centricityResultRepository;
    @Test
    public void initCentricityResult(){
        List<CM_Basic> basicList = basicRepository.findAll();
        List<CM_CentricityResult> dataList = new ArrayList<>();
        for(int i=0; i<100; i++){
            CM_CentricityResult tempData = new CM_CentricityResult();
            CM_Basic tmp_Basic = basicList.get(U.i(basicList.size()));

            tempData.setBasic(tmp_Basic)
                    .setBa_well_id(tmp_Basic.getWell().getBA_WELL_ID())
                    .setCasingSize(U.f(300))
                    .setDepth(U.f(5000))
                    .setResetForce(U.f(500))
                    .setWellName(tmp_Basic.getWellName());
            dataList.add(tempData);
        }
        centricityResultRepository.saveAll(dataList);
    }

    // CM_COLLAR_DESIGN 插入测试数据
    @Autowired
    CM_CollarDesignRepository collarDesignRepository;
    @Test
    public void initCollarDesign(){
        List<CM_Basic> basicList = basicRepository.findAll();
        List<CM_CollarDesign> dataList = new ArrayList<>();
        for(int i=0; i<100; i++){
            CM_CollarDesign tempData = new CM_CollarDesign();
            CM_Basic tmp_Basic = basicList.get(U.i(basicList.size()));

            tempData.setBasic(tmp_Basic)
                    .setBa_well_id(tmp_Basic.getWell().getBA_WELL_ID())
                    .setCasingSize(U.f(300))
                    .setCollarOpenPressure(U.f(3000))
                    .setCollarClosePressure(U.f(3000))
                    .setWellName(tmp_Basic.getWellName());
            dataList.add(tempData);
        }
        collarDesignRepository.saveAll(dataList);
    }

    // CM_COLLAR_WORK 插入测试数据
    @Autowired
    CM_CollarWorkRepository CollarWorkRepository;
    @Test
    public void initCollarWorkData(){
        List<CM_Basic> basicList = basicRepository.findAll();
        List<CM_CollarWork> dataList = new ArrayList<>();
        for(int i=0; i<100; i++){
            CM_CollarWork tempData = new CM_CollarWork();
            CM_Basic tmp_Basic = basicList.get(U.i(basicList.size()));

            tempData.setBasic(tmp_Basic)
                    .setBa_well_id(tmp_Basic.getWell().getBA_WELL_ID())
                    .setCasingSize(U.f(300))
                    .setCollarOpenPressure(U.f(3000))
                    .setCollarClosePressure(U.f(3000))
                    .setWellName(tmp_Basic.getWellName());
            dataList.add(tempData);
        }
        CollarWorkRepository.saveAll(dataList);
    }

    // CM_CYCLE_TEMPERATURE 插入测试数据
    @Autowired
    CM_CycleTemperatureRepository cycleTemperatureRepository;
    @Test
    public void initCycleTempData(){
        List<CM_Basic> basicList = basicRepository.findAll();
        List<CM_CycleTemperature> dataList = new ArrayList<>();
        for(int i=0; i<100; i++){
            CM_CycleTemperature tempData = new CM_CycleTemperature();
            CM_Basic tmp_Basic = basicList.get(U.i(basicList.size()));

            tempData.setBasic(tmp_Basic)
                    .setBa_well_id(tmp_Basic.getWell().getBA_WELL_ID())
                    .setCasingSize(U.f(300))
                    .setTemperature1(U.f(300))
                    .setTemperature2(U.f(300))
                    .setWellName(tmp_Basic.getWellName());
            dataList.add(tempData);
        }
        cycleTemperatureRepository.saveAll(dataList);
    }

    // CM_DISPLACEMENT_EFFICIENCY 插入测试数据
    @Autowired
    CM_DisplacementEfficiencyRepository displacementEfficiencyRepository;
    @Test
    public void initDisplacementEffiData(){
        List<CM_Basic> basicList = basicRepository.findAll();
        List<CM_DisplacementEfficiency> dataList = new ArrayList<>();
        for(int i=0; i<100; i++){
            CM_DisplacementEfficiency tempData = new CM_DisplacementEfficiency();
            CM_Basic tmp_Basic = basicList.get(U.i(basicList.size()));

            tempData.setBasic(tmp_Basic)
                    .setBa_well_id(tmp_Basic.getWell().getBA_WELL_ID())
                    .setCasingSize(U.f(300))
                    .setDepth(U.f(3000))
                    .setFluidDensity(U.f(10))
                    .setWellName(tmp_Basic.getWellName());
            dataList.add(tempData);
        }
        displacementEfficiencyRepository.saveAll(dataList);
    }

    // CM_DPACE_DOSAGE_DESIGN 插入测试数据
    @Autowired
    CM_DpacerDosageDesignRepository dpacerDosageDesignRepository;
    @Test
    public void initDpacerDosageDesignData(){
        List<CM_Basic> basicList = basicRepository.findAll();
        List<CM_DpacerDosageDesign> dataList = new ArrayList<>();
        for(int i=0; i<100; i++){
            CM_DpacerDosageDesign tempData = new CM_DpacerDosageDesign();
            CM_Basic tmp_Basic = basicList.get(U.i(basicList.size()));

            tempData.setBasic(tmp_Basic)
                    .setBa_well_id(tmp_Basic.getWell().getBA_WELL_ID())
                    .setCasingSize(U.f(300))
                    .setDensity(U.f(10))
                    .setCirculation(U.f(100))
                    .setWellName(tmp_Basic.getWellName());
            dataList.add(tempData);
        }
        dpacerDosageDesignRepository.saveAll(dataList);
    }

    // CM_DPACER_EXPERIMENT_BASIC 插入测试数据
    @Autowired
    CM_DpacerExperimentBasicRepository dpacerExperimentBasicRepository;
    @Test
    public void initDpacerExperimentData(){
        List<CM_Basic> basicList = basicRepository.findAll();
        List<CM_DpacerExperimentBasic> dataList = new ArrayList<>();
        for(int i=0; i<100; i++){
            CM_DpacerExperimentBasic tempData = new CM_DpacerExperimentBasic();
            CM_Basic tmp_Basic = basicList.get(U.i(basicList.size()));

            tempData.setBasic(tmp_Basic)
                    .setBa_well_id(tmp_Basic.getWell().getBA_WELL_ID())
                    .setCasingSize(U.f(300))
                    .setBHP(U.f(1000))
                    .setBHCT(U.f(1000))
                    .setWellName(tmp_Basic.getWellName());
            dataList.add(tempData);
        }
        dpacerExperimentBasicRepository.saveAll(dataList);
    }

    // CM_DPACER_EXPERIMENT_COMMISSION 插入测试数据
    @Autowired
    CM_DpacerExperimentCommissionRepository dpacerExperimentCommissionRepository;
    @Test
    public void initDpaceCommission(){
        List<CM_Basic> basicList = basicRepository.findAll();
        List<CM_DpacerExperimentCommission> dataList = new ArrayList<>();
        for(int i=0; i<100; i++){
            CM_DpacerExperimentCommission tempData = new CM_DpacerExperimentCommission();
            CM_Basic tmp_Basic = basicList.get(U.i(basicList.size()));

            tempData.setBasic(tmp_Basic)
                    .setBa_well_id(tmp_Basic.getWell().getBA_WELL_ID())
                    .setCasingSize(U.f(300))
                    .setBeginSet(U.f(1000))
                    .setEndSet(U.f(3000))
                    .setWellName(tmp_Basic.getWellName());
            dataList.add(tempData);
        }
        dpacerExperimentCommissionRepository.saveAll(dataList);
    }

    // CM_DPACER_EXPERIMENT_FORMULA 插入测试数据
    @Autowired
    CM_DpacerExperimentFormulaRepository dpacerExperimentFormulaRepository;
    @Test
    public void initDpacerFormulaData(){
        List<CM_Basic> basicList = basicRepository.findAll();
        List<CM_DpacerExperimentFormula> dataList = new ArrayList<>();
        for(int i=0; i<100; i++){
            CM_DpacerExperimentFormula tempData = new CM_DpacerExperimentFormula();
            CM_Basic tmp_Basic = basicList.get(U.i(basicList.size()));

            tempData.setBasic(tmp_Basic)
                    .setBa_well_id(tmp_Basic.getWell().getBA_WELL_ID())
                    .setCasingSize(U.f(300))
                    .setDosage(U.f(100))
                    .setWeight(U.f(300))
                    .setWellName(tmp_Basic.getWellName());
            dataList.add(tempData);
        }
        dpacerExperimentFormulaRepository.saveAll(dataList);
    }

    // CM_DPACER_EXPERIMENT_PEFORMANCE 插入测试数据
    @Autowired
    CM_DpacerExperimentPerformanceRepository dpacerExperimentPerformanceRepository;
    @Test
    public void initDpacerPerformanceData(){
        List<CM_Basic> basicList = basicRepository.findAll();
        List<CM_DpacerExperimentPerformance> dataList = new ArrayList<>();
        for(int i=0; i<100; i++){
            CM_DpacerExperimentPerformance tempData = new CM_DpacerExperimentPerformance();
            CM_Basic tmp_Basic = basicList.get(U.i(basicList.size()));

            tempData.setBasic(tmp_Basic)
                    .setBa_well_id(tmp_Basic.getWell().getBA_WELL_ID())
                    .setCasingSize(U.f(300))
                    .setColdRpm3(U.f(300))
                    .setColdRpm6(U.f(600))
                    .setWellName(tmp_Basic.getWellName());
            dataList.add(tempData);
        }
        dpacerExperimentPerformanceRepository.saveAll(dataList);
    }

    // CM_DPACER_MATERIAL_CALC 插入测试数据
    @Autowired
    CM_DpacerMaterialCalcRepository dpacerMaterialCalcRepository;
    @Test
    public void initDpacerCalcData(){
        List<CM_Basic> basicList = basicRepository.findAll();
        List<CM_DpacerMaterialCalc> dataList = new ArrayList<>();
        for(int i=0; i<100; i++){
            CM_DpacerMaterialCalc tempData = new CM_DpacerMaterialCalc();
            CM_Basic tmp_Basic = basicList.get(U.i(basicList.size()));

            tempData.setBasic(tmp_Basic)
                    .setBa_well_id(tmp_Basic.getWell().getBA_WELL_ID())
                    .setCasingSize(U.f(300))
                    .setConsumption(U.f(300))
                    .setPreparation(U.f(300))
                    .setWellName(tmp_Basic.getWellName());
            dataList.add(tempData);
        }
        dpacerMaterialCalcRepository.saveAll(dataList);
    }

    // CM_ECD_CALC 插入测试数据
    @Autowired
    CM_EcdCalcRepository ecdCalcRepository;
    @Test
    public void initEcdCalcData(){
        List<CM_Basic> basicList = basicRepository.findAll();
        List<CM_EcdCalc> dataList = new ArrayList<>();
        for(int i=0; i<100; i++){
            CM_EcdCalc tempData = new CM_EcdCalc();
            CM_Basic tmp_Basic = basicList.get(U.i(basicList.size()));

            tempData.setBasic(tmp_Basic)
                    .setBa_well_id(tmp_Basic.getWell().getBA_WELL_ID())
                    .setCasingSize(U.f(300))
                    .setVerticalDepth(U.f(3000))
                    .setContactTime(U.f(300))
                    .setWellName(tmp_Basic.getWellName());
            dataList.add(tempData);
        }
        ecdCalcRepository.saveAll(dataList);
    }

    // CM_ELONGRETRACT_RESULT 插入测试数据
    @Autowired
    CM_ElongretractResultRepository elongretractResultRepository;
    @Test
    public void initElongResultData(){
        List<CM_Basic> basicList = basicRepository.findAll();
        List<CM_ElongretractResult> dataList = new ArrayList<>();
        for(int i=0; i<100; i++){
            CM_ElongretractResult tempData = new CM_ElongretractResult();
            CM_Basic tmp_Basic = basicList.get(U.i(basicList.size()));

            tempData.setBasic(tmp_Basic)
                    .setBa_well_id(tmp_Basic.getWell().getBA_WELL_ID())
                    .setCasingSize(U.f(300))
                    .setBagLength(U.f(3000))
                    .setAmount(U.f(10))
                    .setWellName(tmp_Basic.getWellName());
            dataList.add(tempData);
        }
        elongretractResultRepository.saveAll(dataList);
    }

    // CM_FLUID_PERFORMANCE 插入测试数据
    @Autowired
    CM_FluidPerformanceRepository cm_fluidPerformanceRepository;
    @Test
    public void initCmFluidPerformanceData(){
        List<BA_Well> wellList = wellRepository.findAll();
        List<CM_FluidPerformance> datList = new ArrayList<>();
        for(int i=0; i<100; i++){
            CM_FluidPerformance tmpData = new CM_FluidPerformance();
            BA_Well tmp_well = wellList.get(U.i(wellList.size()));

            tmpData.setWell(tmp_well)
                    .setBitSize(U.f(300))
                    .setRPM3(U.f(30))
                    .setRPM300(U.f(300))
                    .setCasingSize(U.f(3000))
                    .setWellName(tmp_well.getWellName());
            datList.add(tmpData);
        }
        cm_fluidPerformanceRepository.saveAll(datList);
    }

    // CM_FLUID_POSITION 插入测试数据
    @Autowired
    CM_FluidPositionRepository fluidPositionRepository;
    @Test
    public void initFluidPositionData(){
        List<CM_Basic> basicList = basicRepository.findAll();
        List<CM_FluidPosition> dataList = new ArrayList<>();
        for(int i=0; i<100; i++){
            CM_FluidPosition tempData = new CM_FluidPosition();
            CM_Basic tmp_Basic = basicList.get(U.i(basicList.size()));

            tempData.setBasic(tmp_Basic)
                    .setBa_well_id(tmp_Basic.getWell().getBA_WELL_ID())
                    .setFluidNO(U.i(300))
                    .setFluidTopDepth(U.f(3000))
                    .setWellName(tmp_Basic.getWellName());
            dataList.add(tempData);
        }
        fluidPositionRepository.saveAll(dataList);
    }

    // CM_FRICTION_DISTRIBUTION 插入测试数据
    @Autowired
    CM_FrictionDistributionRepository frictionDistributionRepository;
    @Test
    public void initFrictionDistributionData(){
        List<CM_Basic> basicList = basicRepository.findAll();
        List<CM_FrictionDistribution> dataList = new ArrayList<>();
        for(int i=0; i<100; i++){
            CM_FrictionDistribution tempData = new CM_FrictionDistribution();
            CM_Basic tmp_Basic = basicList.get(U.i(basicList.size()));

            tempData.setBasic(tmp_Basic)
                    .setBa_well_id(tmp_Basic.getWell().getBA_WELL_ID())
                    .setCasingSize(U.f(300))
                    .setDepth(U.f(3000))
                    .setAxialForce(U.f(3000))
                    .setWellName(tmp_Basic.getWellName());
            dataList.add(tempData);
        }
        frictionDistributionRepository.saveAll(dataList);
    }

    // CM_FRICATIONDRG_RESULT 插入测试数据
    @Autowired
    CM_FrictiondragResultRepository frictiondragResultRepository;
    @Test
    public void initFrictionDragData(){
        List<CM_Basic> basicList = basicRepository.findAll();
        List<CM_FrictiondragResult> dataList = new ArrayList<>();
        for(int i=0; i<100; i++){
            CM_FrictiondragResult tempData = new CM_FrictiondragResult();
            CM_Basic tmp_Basic = basicList.get(U.i(basicList.size()));

            tempData.setBasic(tmp_Basic)
                    .setBa_well_id(tmp_Basic.getWell().getBA_WELL_ID())
                    .setCasingSize(U.f(300))
                    .setDepth(U.f(3000))
                    .setAzimuth(U.f(30))
                    .setWellName(tmp_Basic.getWellName());
            dataList.add(tempData);
        }
        frictiondragResultRepository.saveAll(dataList);
    }

    // CM_HYDROSTATICPRESSURE 插入测试数据
    @Autowired
    CM_HydrostaticPressureRepository hydrostaticPressureRepository;
    @Test
    public void initHydrostaticData(){
        List<CM_Basic> basicList = basicRepository.findAll();
        List<CM_HydrostaticPressure> dataList = new ArrayList<>();
        for(int i=0; i<100; i++){
            CM_HydrostaticPressure tempData = new CM_HydrostaticPressure();
            CM_Basic tmp_Basic = basicList.get(U.i(basicList.size()));

            tempData.setBasic(tmp_Basic)
                    .setBa_well_id(tmp_Basic.getWell().getBA_WELL_ID())
                    .setCasingSize(U.f(300))
                    .setFluidDensity(U.f(10))
                    .setEMW(U.f(30))
                    .setWellName(tmp_Basic.getWellName());
            dataList.add(tempData);
        }
        hydrostaticPressureRepository.saveAll(dataList);
    }

    // CM_LOG_DATA 插入测试数据
    @Autowired
    CM_LogDataRepository cmlogDataRepository;
    @Test
    public void initCmLogData(){
        List<BA_Well> wellList = wellRepository.findAll();
        List<CM_LogData> basicList = new ArrayList<>();
        for(int i=0; i<100; i++){
            CM_LogData cm_basic = new CM_LogData();
            BA_Well tmp_well = wellList.get(U.i(wellList.size()));

            cm_basic.setWell(tmp_well)
                    .setCasingSize(U.f(300))
                    .setInTemperature(U.f(300))
                    .setOutTemperature(U.f(300))
                    .setWellName(tmp_well.getWellName());
            basicList.add(cm_basic);
        }
        cmlogDataRepository.saveAll(basicList);
    }

    // CM_MUDPUMP_LOG_DATA 插入测试数据
    @Autowired
    CM_MudpumpLogDataRepository mudpumpLogDataRepository;
    @Test
    public void initMudLogData(){
        List<CM_Basic> basicList = basicRepository.findAll();
        List<CM_MudpumpLogData> dataList = new ArrayList<>();
        for(int i=0; i<100; i++){
            CM_MudpumpLogData tempData = new CM_MudpumpLogData();
            CM_Basic tmp_Basic = basicList.get(U.i(basicList.size()));

            tempData.setBasic(tmp_Basic)
                    .setBa_well_id(tmp_Basic.getWell().getBA_WELL_ID())
                    .setCasingSize(U.f(300))
                    .setInTemperature(U.f(300))
                    .setOutTemperature(U.f(300))
                    .setWellName(tmp_Basic.getWellName());
            dataList.add(tempData);
        }
        mudpumpLogDataRepository.saveAll(dataList);
    }

    // CM_PREFLUSH_DOSAGE_DESIGN 插入测试数据 CM_PreflushDosageDesign
    @Autowired
    CM_PreflushDosageDesignRepository preflushDosageDesignRepository;
    @Test
    public void initPreflushDosageData(){
        List<CM_Basic> basicList = basicRepository.findAll();
        List<CM_PreflushDosageDesign> dataList = new ArrayList<>();
        for(int i=0; i<100; i++){
            CM_PreflushDosageDesign tempData = new CM_PreflushDosageDesign();
            CM_Basic tmp_Basic = basicList.get(U.i(basicList.size()));

            tempData.setBasic(tmp_Basic)
                    .setBa_well_id(tmp_Basic.getWell().getBA_WELL_ID())
                    .setCasingSize(U.f(300))
                    .setDensity(U.f(10))
                    .setDosage(U.f(300))
                    .setWellName(tmp_Basic.getWellName());
            dataList.add(tempData);
        }
        preflushDosageDesignRepository.saveAll(dataList);
    }

    // CM_PREFLUSH_EXPERIMENT_BASIC 插入测试数据
    @Autowired
    CM_PreflushExperimentBasicRepository preflushExperimentBasicRepository;
    @Test
    public void initPreflushBasicData(){
        List<CM_Basic> basicList = basicRepository.findAll();
        List<CM_PreflushExperimentBasic> dataList = new ArrayList<>();
        for(int i=0; i<100; i++){
            CM_PreflushExperimentBasic tempData = new CM_PreflushExperimentBasic();
            CM_Basic tmp_Basic = basicList.get(U.i(basicList.size()));

            tempData.setBasic(tmp_Basic)
                    .setBa_well_id(tmp_Basic.getWell().getBA_WELL_ID())
                    .setCasingSize(U.f(300))
                    .setWellDepth(U.f(5000))
                    .setTemperatureGradient(U.f(30))
                    .setWellName(tmp_Basic.getWellName());
            dataList.add(tempData);
        }
        preflushExperimentBasicRepository.saveAll(dataList);
    }

    // CM_PREFLUSH_EXPERIMENT_COMMISSION 插入测试数据
    @Autowired
    CM_PreflushExperimentCommissionRepository preflushExperimentCommissionRepository;
    @Test
    public void initPreflushCommissionData(){
        List<CM_Basic> basicList = basicRepository.findAll();
        List<CM_PreflushExperimentCommission> dataList = new ArrayList<>();
        for(int i=0; i<100; i++){
            CM_PreflushExperimentCommission tempData = new CM_PreflushExperimentCommission();
            CM_Basic tmp_Basic = basicList.get(U.i(basicList.size()));

            tempData.setBasic(tmp_Basic)
                    .setBa_well_id(tmp_Basic.getWell().getBA_WELL_ID())
                    .setCasingSize(U.f(300))
                    .setBHSP(U.f(50))
                    .setTemperatureGradient(U.f(30))
                    .setWellName(tmp_Basic.getWellName());
            dataList.add(tempData);
        }
        preflushExperimentCommissionRepository.saveAll(dataList);
    }

    // CM_PREFLUSH_EXPERIMENT_FORMULA 插入测试数据
    @Autowired
    CM_PreflushExperimentFormulaRepository preflushExperimentFormulaRepository;
    @Test
    public void initPreflushFormulaData(){
        List<CM_Basic> basicList = basicRepository.findAll();
        List<CM_PreflushExperimentFormula> dataList = new ArrayList<>();
        for(int i=0; i<100; i++){
            CM_PreflushExperimentFormula tempData = new CM_PreflushExperimentFormula();
            CM_Basic tmp_Basic = basicList.get(U.i(basicList.size()));

            tempData.setBasic(tmp_Basic)
                    .setBa_well_id(tmp_Basic.getWell().getBA_WELL_ID())
                    .setCasingSize(U.f(300))
                    .setDosage(U.f(50))
                    .setVol(U.f(300))
                    .setWellName(tmp_Basic.getWellName());
            dataList.add(tempData);
        }
        preflushExperimentFormulaRepository.saveAll(dataList);
    }

    // CM_PREFLUSH_EXPERIMENT_PERFORMANCE 插入测试数据
    @Autowired
    CM_PreflushExperimentPerformanceRepository preflushExperimentPerformanceRepository;
    @Test
    public void initPreflushPerformanceData(){
        List<CM_Basic> basicList = basicRepository.findAll();
        List<CM_PreflushExperimentPerformance> dataList = new ArrayList<>();
        for(int i=0; i<100; i++){
            CM_PreflushExperimentPerformance tempData = new CM_PreflushExperimentPerformance();
            CM_Basic tmp_Basic = basicList.get(U.i(basicList.size()));

            tempData.setBasic(tmp_Basic)
                    .setBa_well_id(tmp_Basic.getWell().getBA_WELL_ID())
                    .setCasingSize(U.f(300))
                    .setColdRpm30(U.f(30))
                    .setDensity(U.f(10))
                    .setWellName(tmp_Basic.getWellName());
            dataList.add(tempData);
        }
        preflushExperimentPerformanceRepository.saveAll(dataList);
    }

    // CM_PREFLUSH_MATERIAL_CALC 插入测试数据
    @Autowired
    CM_PreflushMaterialCalcRepository preflushMaterialCalcRepository;
    @Test
    public void initPreflushCalcData(){
        List<CM_Basic> basicList = basicRepository.findAll();
        List<CM_PreflushMaterialCalc> dataList = new ArrayList<>();
        for(int i=0; i<100; i++){
            CM_PreflushMaterialCalc tempData = new CM_PreflushMaterialCalc();
            CM_Basic tmp_Basic = basicList.get(U.i(basicList.size()));

            tempData.setBasic(tmp_Basic)
                    .setBa_well_id(tmp_Basic.getWell().getBA_WELL_ID())
                    .setCasingSize(U.f(300))
                    .setConsumption(U.f(300))
                    .setPreparation(U.f(500))
                    .setWellName(tmp_Basic.getWellName());
            dataList.add(tempData);
        }
        preflushMaterialCalcRepository.saveAll(dataList);
    }

    // CM_RHEOLOGICAL_MATCH 插入测试数据
    @Autowired
    CM_RheologicalMatchRepository rheologicalMatchRepository;
    @Test
    public void initRheologyMatchData(){
        List<CM_Basic> basicList = basicRepository.findAll();
        List<CM_RheologicalMatch> dataList = new ArrayList<>();
        for(int i=0; i<100; i++){
            CM_RheologicalMatch tempData = new CM_RheologicalMatch();
            CM_Basic tmp_Basic = basicList.get(U.i(basicList.size()));

            tempData.setBasic(tmp_Basic)
                    .setBa_well_id(tmp_Basic.getWell().getBA_WELL_ID())
                    .setCasingSize(U.f(300))
                    .setOutDiameter(U.f(300))
                    .setInDiameter(U.f(200))
                    .setWellName(tmp_Basic.getWellName());
            dataList.add(tempData);
        }
        rheologicalMatchRepository.saveAll(dataList);
    }

    // CM_RUBBER_PLUG_DESIGN 插入测试数据
    @Autowired
    CM_RubberPlugDesignRepository rubberPlugDesignRepository;
    @Test
    public void initRubberPlugDegisnData(){
        List<CM_Basic> basicList = basicRepository.findAll();
        List<CM_RubberPlugDesign> dataList = new ArrayList<>();
        for(int i=0; i<100; i++){
            CM_RubberPlugDesign tempData = new CM_RubberPlugDesign();
            CM_Basic tmp_Basic = basicList.get(U.i(basicList.size()));

            tempData.setBasic(tmp_Basic)
                    .setBa_well_id(tmp_Basic.getWell().getBA_WELL_ID())
                    .setCasingSize(U.f(300))
                    .setDiameter1(U.f(300))
                    .setDiameter2(U.f(200))
                    .setWellName(tmp_Basic.getWellName());
            dataList.add(tempData);
        }
        rubberPlugDesignRepository.saveAll(dataList);
    }

    // CM_RUBBER_PLUG_WORK 插入测试数据
    @Autowired
    CM_RubberPlugWorkRepository rubberPlugWorkRepository;
    @Test
    public void initRubberWorkData(){
        List<CM_Basic> basicList = basicRepository.findAll();
        List<CM_RubberPlugWork> dataList = new ArrayList<>();
        for(int i=0; i<100; i++){
            CM_RubberPlugWork tempData = new CM_RubberPlugWork();
            CM_Basic tmp_Basic = basicList.get(U.i(basicList.size()));

            tempData.setBasic(tmp_Basic)
                    .setBa_well_id(tmp_Basic.getWell().getBA_WELL_ID())
                    .setCasingSize(U.f(300))
                    .setDiameter1(U.f(300))
                    .setDiameter2(U.f(200))
                    .setWellName(tmp_Basic.getWellName());
            dataList.add(tempData);
        }
        rubberPlugWorkRepository.saveAll(dataList);
    }

    // CM_SLURRY_EXPERIMENT_BASIC 插入测试数据
    @Autowired
    CM_SlurryDosageDesignRepository slurryDosageDesignRepository;
    @Test
    public void initSlurryDesignData(){
        List<CM_Basic> basicList = basicRepository.findAll();
        List<CM_SlurryDosageDesign> dataList = new ArrayList<>();
        for(int i=0; i<100; i++){
            CM_SlurryDosageDesign tempData = new CM_SlurryDosageDesign();
            CM_Basic tmp_Basic = basicList.get(U.i(basicList.size()));

            tempData.setBasic(tmp_Basic)
                    .setBa_well_id(tmp_Basic.getWell().getBA_WELL_ID())
                    .setCasingSize(U.f(300))
                    .setTopDepth(U.f(3000))
                    .setBitSize(U.f(200))
                    .setWellName(tmp_Basic.getWellName());
            dataList.add(tempData);
        }
        slurryDosageDesignRepository.saveAll(dataList);
    }

    // CM_SLURRY_EXPERIMENT_BASIC 插入测试数据
    @Autowired
    CM_SlurryExperimentBasicRepository slurryExperimentBasicRepository;
    @Test
    public void initSlurryBasicData(){
        List<CM_Basic> basicList = basicRepository.findAll();
        List<CM_SlurryExperimentBasic> dataList = new ArrayList<>();
        for(int i=0; i<100; i++){
            CM_SlurryExperimentBasic tempData = new CM_SlurryExperimentBasic();
            CM_Basic tmp_Basic = basicList.get(U.i(basicList.size()));

            tempData.setBasic(tmp_Basic)
                    .setBa_well_id(tmp_Basic.getWell().getBA_WELL_ID())
                    .setCasingSize(U.f(300))
                    .setWellDepth(U.f(3000))
                    .setBHCT(U.f(200))
                    .setWellName(tmp_Basic.getWellName());
            dataList.add(tempData);
        }
        slurryExperimentBasicRepository.saveAll(dataList);
    }

    // CM_SLURRY_EXPERIMENT_COMMISSION
    @Autowired
    CM_SlurryExperimentCommissionRepository slurryExperimentCommissionRepository;
    @Test
    public void initSlurryCommissionData(){
        List<CM_Basic> basicList = basicRepository.findAll();
        List<CM_SlurryExperimentCommission> dataList = new ArrayList<>();
        for(int i=0; i<100; i++){
            CM_SlurryExperimentCommission tempData = new CM_SlurryExperimentCommission();
            CM_Basic tmp_Basic = basicList.get(U.i(basicList.size()));

            tempData.setBasic(tmp_Basic)
                    .setBa_well_id(tmp_Basic.getWell().getBA_WELL_ID())
                    .setCasingSize(U.f(300))
                    .setDensity(U.f(10))
                    .setDepth(U.f(3000))
                    .setWellName(tmp_Basic.getWellName());
            dataList.add(tempData);
        }
        slurryExperimentCommissionRepository.saveAll(dataList);
    }

    // CM_SLURRY_EXPERIMENT_FORMULA 插入测试数据
    @Autowired
    CM_SlurryExperimentFormulaRepository cm_slurryExperimentFormulaRepository;
    @Test
    public void initSlurryFormulaData(){
        List<CM_Basic> basicList = basicRepository.findAll();
        List<CM_SlurryExperimentFormula> dataList = new ArrayList<>();
        for(int i=0; i<100; i++){
            CM_SlurryExperimentFormula tempData = new CM_SlurryExperimentFormula();
            CM_Basic tmp_Basic = basicList.get(U.i(basicList.size()));

            tempData.setBasic(tmp_Basic)
                    .setBa_well_id(tmp_Basic.getWell().getBA_WELL_ID())
                    .setCasingSize(U.f(300))
                    .setMaterialDensity(U.f(10))
                    .setVol(U.f(2000))
                    .setWellName(tmp_Basic.getWellName());
            dataList.add(tempData);
        }
        cm_slurryExperimentFormulaRepository.saveAll(dataList);
    }

    // CM_SLURRY_EXPERIMENT_PERFORMANCE 插入测试数据
    @Autowired
    CM_SlurryExperimentPerformanceRepository cm_slurryExperimentPerformanceRepository;
    @Test
    public void initSlurryPerformanceData(){
        List<CM_Basic> basicList = basicRepository.findAll();
        List<CM_SlurryExperimentPerformance> dataList = new ArrayList<>();
        for(int i=0; i<100; i++){
            CM_SlurryExperimentPerformance tempData = new CM_SlurryExperimentPerformance();
            CM_Basic tmp_Basic = basicList.get(U.i(basicList.size()));

            tempData.setBasic(tmp_Basic)
                    .setBa_well_id(tmp_Basic.getWell().getBA_WELL_ID())
                    .setCasingSize(U.f(300))
                    .setBc30(U.f(30))
                    .setBc40(U.f(40))
                    .setWellName(tmp_Basic.getWellName());
            dataList.add(tempData);
        }
        cm_slurryExperimentPerformanceRepository.saveAll(dataList);
    }

    // CM_SLURRY_MATERIAL_CALC 插入测试数据
    @Autowired
    CM_SlurryMaterialCalcRepository cmSlurryMaterialCalcRepository;
    @Test
    public void initSlurryCalcData(){
        List<CM_Basic> basicList = basicRepository.findAll();
        List<CM_SlurryMaterialCalc> dataList = new ArrayList<>();
        for(int i=0; i<100; i++){
            CM_SlurryMaterialCalc tempData = new CM_SlurryMaterialCalc();
            CM_Basic tmp_Basic = basicList.get(U.i(basicList.size()));

            tempData.setBasic(tmp_Basic)
                    .setBa_well_id(tmp_Basic.getWell().getBA_WELL_ID())
                    .setCasingSize(U.f(300))
                    .setCementConsumption(U.f(300))
                    .setMaterialReady(U.f(400))
                    .setWellName(tmp_Basic.getWellName());
            dataList.add(tempData);
        }
        cmSlurryMaterialCalcRepository.saveAll(dataList);
    }

    // CM_WATER_TEST 插入测试数据
    @Autowired
    CM_WaterTestRepository waterTestRepository;
    @Test
    public void initWaterTestData(){
        List<BA_Well> wellList = wellRepository.findAll();
        List<CM_WaterTest> basicList = new ArrayList<>();
        for(int i=0; i<100; i++){
            CM_WaterTest cm_basic = new CM_WaterTest();
            BA_Well tmp_well = wellList.get(U.i(wellList.size()));

            cm_basic.setWell(tmp_well)
                    .setBase_CL(U.f(10))
                    .setCasingSize(U.f(300))
                    .setMix_CL1(U.f(20))
                    .setMix_CL2(U.f(30))
                    .setWellName(tmp_well.getWellName());
            basicList.add(cm_basic);
        }
        waterTestRepository.saveAll(basicList);
    }

    // CM_WK_LINERHANGER_DESIGNDATA 插入测试数据
    @Autowired
    CM_WK_LinerhangerDesignDataRepository linerhangerDesignDataRepository;
    @Test
    public void initLinerDesignData(){
        List<CM_Basic> basicList = basicRepository.findAll();
        List<CM_WK_LinerhangerDesignData> dataList = new ArrayList<>();
        for(int i=0; i<100; i++){
            CM_WK_LinerhangerDesignData tempData = new CM_WK_LinerhangerDesignData();
            CM_Basic tmp_Basic = basicList.get(U.i(basicList.size()));

            tempData.setBasic(tmp_Basic)
                    .setBa_well_id(tmp_Basic.getWell().getBA_WELL_ID())
                    .setCasingSize(U.f(300))
                    .setBallPressure1(U.f(3000))
                    .setTopSealWeight1(U.f(4000))
                    .setWellName(tmp_Basic.getWellName());
            dataList.add(tempData);
        }
        linerhangerDesignDataRepository.saveAll(dataList);
    }

    // CM_WK_LinerhangerWorkData 插入测试数据
    @Autowired
    CM_WK_LinerhangerWorkDataRepository linerhangerWorkDataRepository;
    @Test
    public void initLinerWorkData(){
        List<CM_Basic> basicList = basicRepository.findAll();
        List<CM_WK_LinerhangerWorkData> dataList = new ArrayList<>();
        for(int i=0; i<100; i++){
            CM_WK_LinerhangerWorkData tempData = new CM_WK_LinerhangerWorkData();
            CM_Basic tmp_Basic = basicList.get(U.i(basicList.size()));

            tempData.setBasic(tmp_Basic)
                    .setBa_well_id(tmp_Basic.getWell().getBA_WELL_ID())
                    .setCasingSize(U.f(300))
                    .setBallPressure1(U.f(3000))
                    .setTopSealWeight1(U.f(4000))
                    .setWellName(tmp_Basic.getWellName());
            dataList.add(tempData);
        }
        linerhangerWorkDataRepository.saveAll(dataList);
    }

    // CM_WORK_EFFICIENCY_DESIGN 插入测试数据
    @Autowired
    CM_WorkEfficiencyDesignRepository workEfficiencyDesignRepository;
    @Test
    public void initWorkEfficiencyData(){
        List<CM_Basic> basicList = basicRepository.findAll();
        List<CM_WorkEfficiencyDesign> dataList = new ArrayList<>();
        for(int i=0; i<100; i++){
            CM_WorkEfficiencyDesign tempData = new CM_WorkEfficiencyDesign();
            CM_Basic tmp_Basic = basicList.get(U.i(basicList.size()));

            tempData.setBasic(tmp_Basic)
                    .setBa_well_id(tmp_Basic.getWell().getBA_WELL_ID())
                    .setCasingSize(U.f(300))
                    .setInjectionVolume(U.f(1000))
                    .setOutTemperature(U.f(400))
                    .setWellName(tmp_Basic.getWellName());
            dataList.add(tempData);
        }
        workEfficiencyDesignRepository.saveAll(dataList);
    }


    private static class U {

        static boolean r() {
            return Math.random() < 0.5;
        }

        static Double f(int multiple) {
            return f(2, multiple);
        }

        static Double f(int size, int multiple) {
            return new BigDecimal(Math.random() * multiple).setScale(size, BigDecimal.ROUND_HALF_UP).doubleValue();
        }

        static int i(int size) {
            Random random = new Random();
            return random.nextInt(size);
        }

        static String coordinate() {
            return f(150) + "^" + f(150);
        }

        static void swap(int a, int b) {
            int temp = a;
            a = b;
            b = temp;
        }

        ;
    }

}
